(function($, window, document, undefined) {
	$.suredy = {};

	// suredy plugins
	$.suredy.loadContent = function(uri, selector, params, callback) {
		if (!uri || uri == '') {
			alert('Invalid uri, please check the [data-uri] on element.');
			return;
		}

		selector = selector || 'div.suredy-content';

		var ele;

		if (selector instanceof jQuery)
			ele = selector;
		else if (typeof selector === 'string') {
			ele = $(selector);
		} else
			return;

		ele.html('<i class="icon-spinner icon-spin icon-2x suredy-icon-loading"></i>');

		if ($.isFunction(params)) {
			callback = params;
			params = undefined;
		}

		ele.load(uri, params, function(response, status, request) {
			if ('success' === status) {
				var html = $('<div>').append($.parseHTML(response));
				var meta = html.find('meta[property=type]');

				if (meta.length > 0 && meta.attr('value') === 'login') {
					window.location.href = 'login.do';
					return false;
				}

				if (callback) {
					callback.call();
				}

				return true;
			} else {
				alert('Bad request! Please check it.');
				return false;
			}
		});
	};

	// notify config
	if ($.notifyDefaults)
		$.notifyDefaults({
			allow_dismiss : false,
			placement : {
				align : 'center'
			},
			delay : 3000,
			mouse_over : 'pause',
			animate : {
				enter : 'animated flipInX',
				exit : 'animated flipOutX'
			}
		});
})(jQuery, window, document);
